// 当我在终端输入 node 2.js rock（石头）时希望电脑随机出一个，并输出对战结果。

//console.log(process.argv);

var playerAction = process.argv[process.argv.length - 1];
//console.log(player);

//电脑随机生成 3 个
var random = Math.random() * 3
if(random < 1){
    var computerAction = 'rock'
}else if(random > 2){
    var computerAction = 'scissor'
}else {
    var computerAction = 'paper'
}

//比较
if(computerAction == playerAction){
    console.log('平局');
}else if((computerAction === 'rock' && playerAction === 'paper') || (computerAction === 'scissor' && playerAction === 'rock') ||(computerAction === 'paper' || playerAction === 'scissor')){
console.log('You win.');
}else{
    console.log('You lose.');
}